<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-6-3
 * Func   返点
 */
defined('IN_YuLin') || exit('NO PERMIT!');

$table = Table('user_money_rebate');
$utable = Table('user');

if($a == 'add')
{
	
}
else
{
	$data  = array();
	$where = ' FROM '.$table.' t LEFT JOIN '.$utable.' u ON t.suid = u.id WHERE t.uid = '.$_uid;
    
    $uid = intval($_GET['uid']);
	$uid && $where .= ' AND t.suid = '.$uid;
	
	//	时间
	$dt1 = NoBadStr($_GET['dt1']);
	$dt1 && $where .= ' AND t.dateline >= '.strtotime($dt1);
	$dt2 = NoBadStr($_GET['dt2']);
	$dt2 && $where .= ' AND t.dateline <= '.strtotime($dt2);
	
	$tmp = $db->getrow('SELECT COUNT(1) AS p '.$where);
	if($tmp['p'])
	{
		$page = max(1,intval($_GET['page']));
		$size = 20;
		$limit    = ' LIMIT '.($page - 1) * $size.','.$size;
		
		$orderby = ' ORDER BY t.id DESC ';
		$url = '?m='.$m.'&c='.$c.'&a='.$a.'&dt1='.$dt1.'&dt2='.$dt2.'&uid='.$uid;
		
		$data = $db->getall('SELECT t.*,u.username '.$where.$orderby.$limit);
		
		$multi = Multi($url,$page,$tmp['p'],$size);
	}
	
	$tpl->display('user/rebate');
}